<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<script src="../../js/lib/jquery-v3.0.0/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/lib/jquery-sammy-v0.7.6/sammy.js" type="text/javascript" charset="utf-8"></script>
		<title>jquery.sammy</title>
	</head>

	<body>
		<div id="main">
			<div class="btn-list"></div>
			<div id="content">
				hi,everyone...
			</div>
		</div>
		<script type="text/javascript">
			var app = Sammy('#main', function() {
				this.get('#/', function() {
					this.trigger('page:index:loaded');
					this.trigger('test', {
						my_data: 'EVENTED!'
					});
				})

				// bind(name, callback)
				this.bind('page:first:loaded', function(e, data) {
					$('#main').css('background-color', 'yellow');
				});
				this.bind('page:index:loaded', function(e, data) {
					$('#main').css('font-size', random(40) + 'px');
				});
				this.bind('test', function(e, data) {
					alert(data['my_data']);
				});
			})
			app.run('#/');
			app.trigger('page:first:loaded');

			function random(x) {
				return Math.floor((Math.random() * x) + 12);
			}
		</script>
	</body>

</html>